import Vue from 'vue';
import VueRouter from 'vue-router';
import layout from "@/layout"

Vue.use(VueRouter);

let basicRoutes = []
function importAllRouter(res) {
    res.keys().forEach(key => {
        basicRoutes.push(res(key).default)
    });
}
importAllRouter(require.context('./module/constantRouter', false, /\.routes.js$/));

const router = new VueRouter({
    scrollBehavior: () => ({ y: 0 }),
    routes: [
        {
            component: layout,
            path: "/",
            name: "root",
            children: basicRoutes,
        },
        {
            path: "/login",
            name: "login",
            meta: { title: "login" },
            component: () => import('@/views/login/index.vue')
        },
        {
            path: "/404",
            name: "404",
            meta: { title: "404" },
            component: () => import('@/views/404/index.vue')
        },
    ]
});
export default router;
